﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace B.MES.Customer.Read.WebApi
{
    public class ExFilter : IExceptionFilter
    {
        /// <summary>
        /// 日志服务
        /// </summary>
        private readonly ILogger<ExFilter> logger;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="logger">日志服务</param>
        public ExFilter(ILogger<ExFilter> logger)
        {
            this.logger = logger;
        }
        /// <summary>
        /// 异常过滤器
        /// </summary>
        /// <param name="context"></param>
        public void OnException(ExceptionContext context)
        {
            logger.LogError("过滤器异常信息" + context.Exception.Message);
        }
    }
}
